package com.ltkj.shop.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ltkj.common.log.annotation.Log;
import com.ltkj.common.log.enums.BusinessType;
import com.ltkj.common.security.annotation.RequiresPermissions;
import com.ltkj.shop.domain.ShopHotelRoom;
import com.ltkj.shop.service.IShopHotelRoomService;
import com.ltkj.common.core.web.controller.BaseController;
import com.ltkj.common.core.web.domain.AjaxResult;
import com.ltkj.common.core.utils.poi.ExcelUtil;
import com.ltkj.common.core.web.page.TableDataInfo;

/**
 * 酒店房间Controller
 * 
 * @author xupf
 * @date 2023-08-29
 */
@Api(tags = "酒店房间")
@RestController
@RequestMapping("/hotel/room")
public class ShopHotelRoomController extends BaseController
{
    @Autowired
    private IShopHotelRoomService shopHotelRoomService;

    /**
     * 查询酒店房间列表
     */
    @ApiOperation("查询酒店房间列表")
//    @RequiresPermissions("shop:hotelRoom:list")
    @GetMapping("/list")
    public TableDataInfo list(ShopHotelRoom shopHotelRoom)
    {
        startPage();
        List<ShopHotelRoom> list = shopHotelRoomService.selectShopHotelRoomList(shopHotelRoom);
        return getDataTable(list);
    }

    /**
     * 导出酒店房间列表
     */
    @ApiOperation("导出酒店房间列表")
//    @RequiresPermissions("shop:hotelRoom:export")
    @Log(title = "酒店房间", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShopHotelRoom shopHotelRoom)
    {
        List<ShopHotelRoom> list = shopHotelRoomService.selectShopHotelRoomList(shopHotelRoom);
        ExcelUtil<ShopHotelRoom> util = new ExcelUtil<ShopHotelRoom>(ShopHotelRoom.class);
        util.exportExcel(response, list, "酒店房间数据");
    }

    /**
     * 获取酒店房间详细信息
     */
    @ApiOperation("获取酒店房间详细信息")
//    @RequiresPermissions("shop:hotelRoom:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(shopHotelRoomService.selectShopHotelRoomById(id));
    }

    /**
     * 新增酒店房间
     */
    @ApiOperation("新增酒店房间")
//    @RequiresPermissions("shop:hotelRoom:add")
    @Log(title = "酒店房间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShopHotelRoom shopHotelRoom)
    {
        return success(shopHotelRoomService.insertShopHotelRoom(shopHotelRoom));
    }

    /**
     * 修改酒店房间
     */
    @ApiOperation("修改酒店房间")
//    @RequiresPermissions("shop:hotelRoom:edit")
    @Log(title = "酒店房间", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShopHotelRoom shopHotelRoom)
    {
        return toAjax(shopHotelRoomService.updateShopHotelRoom(shopHotelRoom));
    }

    /**
     * 删除酒店房间
     */
    @ApiOperation("删除酒店房间")
//    @RequiresPermissions("shop:hotelRoom:remove")
    @Log(title = "酒店房间", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(shopHotelRoomService.deleteShopHotelRoomByIds(ids));
    }
}
